var PRO=PRO||{};
PRO.charts=(function(){
	function ajaxFetchJson(url,param,callBack,$dom){
		  $.ajax({
              url: url,
              type: "post",
              data:param,
              success: function (data, status) {
              	if(data){
              		method[callBack](data,$dom);
              	}
              }
          });
	}
	var method={
			renderHistogramDataChart:function(retOption,$dom){
				option = {
						 title : {
						        text: retOption.titleText,
						        subtext: '',
						        x:'center'
						    },
					    color: ['#000000'],
					    tooltip : {
					        trigger: 'axis',
					        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
					            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
					        }
					    },
					    grid: {
					        left: '1%',
					        right: '1%',
					        bottom: '12%',
					        containLabel: true
					    },
					    xAxis : [
					        {
					            type : 'category',
					            data : retOption.xAxis.data,
					            axisTick: {
					                alignWithLabel: true
					            }, axisLabel:{
					            	rotate:retOption.rotate||0,
					            	 interval: 0,
					            	 formatter:function(val){
					            		    return val;
					            		}
					            }
					        }
					    ],
					    yAxis : [
					        {
					            type : 'value'
					        }
					    ],
					    series : [
					        {
					            name:retOption.seriesName,
					            type:'bar',
					            barWidth: '30%',
					            data:retOption.series,
					            itemStyle:{
					            	normal:{
					            		 color: retOption.barColor||"#0080FF"
					            	}
					            }
					        }
					    ]
					};
				
				var chart = echarts.init($dom[0]);
				chart.setOption(option);
			}
	};
	//初始化用户增长量饼图
	function initHistogramChart(url,param,$dom){
		ajaxFetchJson(url,param,"renderHistogramDataChart",$dom);
	}
	
	return {
		initHistogramChart:initHistogramChart
	};
})();
